<!DOCTYPE html>
<script src="../../../resources/js-test.js"></script>
<script>
window.onload = function() {
    var checkbox = document.getElementById('checkbox');
    var label = document.getElementById('label');

    shouldBeFalse('checkbox.checked');

    if (window.eventSender) {
        eventSender.mouseMoveTo(label.offsetLeft, label.offsetTop);

        eventSender.mouseDown();
        eventSender.mouseUp();
        shouldBeTrue('checkbox.checked');

        eventSender.leapForward(1000);
        eventSender.mouseDown();
        eventSender.mouseUp();
        shouldBeFalse('checkbox.checked');
    }

    label.click();
    shouldBeTrue('checkbox.checked');

    label.click();
    shouldBeFalse('checkbox.checked');

    window.getSelection().selectAllChildren(label);
    label.click();
    shouldBeTrue('checkbox.checked');

    label.click();
    shouldBeFalse('checkbox.checked');
};
</script>
<input id="checkbox" type="checkbox">
<label id="label" for="checkbox">Label</label>
<div id="console"></div>
